package com.huiben.app.cartoonbooks.net;

import android.util.Log;

import com.huiben.app.cartoonbooks.app.FrameBean;
import com.huiben.app.cartoonbooks.base.entity.BaseEntity;
import com.huiben.app.cartoonbooks.base.entity.BaseInfo;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okrx.RxAdapter;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by LXR on 2017/1/20.
 */

public class API {


    public static Observable<BaseEntity<String>>login(String username,String password){
        return OkGo.post("http://www.huibenabc.com/app/neahow/huibenapi/api1.0/passport.php?ac=register")
                .params("username",username)
                .params("password",password)
                .getCall(new JsonConvert<BaseEntity<String>>(){}, RxAdapter.<BaseEntity<String>>create())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
// 获取播放列表
    public static Observable<BaseInfo<FrameBean>>getplays(){
        Log.e("API", "getplays: " );



        return OkGo.get("http://www.huibenabc.com/app/neahow/huibenapi/api1.0/plays.php?ac=play_view&rand=7")
                .cacheKey("1234")
                .cacheMode(CacheMode.FIRST_CACHE_THEN_REQUEST)


                .getCall(new JsonConvert<BaseInfo<FrameBean>>(){}, RxAdapter.<BaseInfo<FrameBean>>create())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());

    }
}
